<template>
	<view :style="$theme.pageStyle">


		<view class="content_nav" style="margin: 15px;">
			<view style="display: flex;">
				<span style="margin-right: 5px;margin-left: 3px;">
					<sh-address v-model:codeValue="valCode" v-model="val" @change="changeCity"
						@columnchange="columnchange">
						{{city}}
					</sh-address>
				</span>
				<u-icon name="arrow-down" size="12"></u-icon>
			</view>
		</view>

		<view class="lawyer_list">
			<block v-for="(item , index ) in DataList" :key="index">
				<view class="law_list recommend-conent" @click="Tourl('/lawyer/all/info?id=' + item.detailid)">
					<view class="lawyer-list">
						<view class="lawyer home">
							<view class="lawyer-left">
								<view class="lawyer-left-info">
									<view class="lawyer-left-info-img">
										<image :src="item.pic" mode="aspectFill"></image>
									</view>
								</view>
							</view>
							<view class="lawyer-right">
								<view class="lawyer-right-name">
									<view class="lawyer-right-name-left">
										{{item.name}}
									</view>
									<view class="lawyer-right-name-right l-color-theme">
										{{item.city ? item.city : item.province}}
									</view>
								</view>
								<view class="lawyer-right-time">
									
									<view class="lawyer-right-time-right">
										{{item.firm}}
									</view>
									<view class="lawyer-right-time-right">
										{{item.speciality}}
									</view>

								</view>

								<view class="lawyer-right-btn-position">
									<view class="lawyer-right-btn-right">
										<view class="lawyer-right-btn-right-info">
											在线咨询
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</block>
		</view>

		<view style="height: 40px;"></view>
	</view>
</template>

<script>
	import statusPoint from '@/components/status.vue'
	import $H from '@/common/js/request.js';
	export default {
		components: {
			statusPoint
		},
		data() {
			return {
				city: uni.getStorageSync('city'),
				province: uni.getStorageSync('province'),
				isLogin: '',
				keyword: "",
				scrollTop: 0,
				indexData: 0,
				navs: [],
				cate: [],
				lawyer: [],
				office: [],
				DataList: [],
				Cate: [],
				limit: 40
			}
		},
		onLoad(opt) {
			this.timeer()
			if (uni.getStorageSync('token') == '') {
				this.isLogin = 0
			} else {
				this.isLogin = 1
			}
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		onReachBottom() {
			this.GetData();
		},
		methods: {
			changeCity(e) {
				if(e.city === '市辖区'){
					this.province =  e.province
					this.timeer();
					
					return this.city = e.province
				}
				this.city = e.city
				this.province = e.province
				
				this.DataList = [];
				this.isLoading = false;
				this.scroll = false;
				this.status = 0;
				this.pages = 1;
				this.page = 0;
				this.out = 0;
				this.GetData();
				
				
			},
			timeer() {
				this.DataList = [];
				this.isLoading = false;
				this.scroll = false;
				this.status = 0;
				this.pages = 1;
				this.page = 0;
				this.out = 0;
				this.GetData();
			},
			GetData(e) {
				
				console.log("page" + this.page)
				console.log("pages" + this.pages)
				
				this.out = 0;
				this.isLoading = true;
				this.scroll = false;
				this.limit = 15;
				var page = this.page;
				$H.post('search/searchAllLawyer', {
					'page': page,
					'limit': this.limit,
					'keyword': this.province
				}, {
					token: true
				}).then(res => {
					// console.log(res)
					if (res.code == 1) {
						var list = res.data.list;
						for (let i = 0; i < list.length; i++) {
							//将数据逐条写入数组
							this.DataList.push(list[i]);
						}
				
						this.page = res.data.start + 40;
						
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				})
				
				
				
			},
			Tourl(url) {
				uni.navigateTo({
					url: url
				})
			},
			custom(value) {
				this.keyword = value
				this.timeer()
			},
			ToCate(item) {
				uni.setStorageSync('S_title_Cate', item.title)
				uni.navigateTo({
					url: '/pages/index/cate?id=' + item.id
				})
			}
		}
	}
</script>

<style>
	page {
		/* background: #fff; */
	}
</style>
<style lang="scss" scoped>
	@import '@/common/css/lawyer.scss';

	.search {
		margin: 10px;
	}

	.navs {
		margin: 10px;

		.types {
			background: #fff;
			border-radius: 13px;
			margin-top: 13px;
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			width: 100%;

			.tyIm {
				display: flex;
				flex-direction: column;
				width: 25%;
				height: 88px;
				justify-content: center;
				align-items: center;
				border-right: 1px solid #f2f3f4;
				border-bottom: 1px solid #f2f3f4;
			}

			.tyIm image {
				width: 35px;
				height: 35px;
			}

			.tyIm text {
				font-size: 13px;
			}
		}
	}
</style>